﻿Imports System.Data
Imports System.IO
Imports System.Data.OleDb
Imports System.Timers

Public Class CCargaVALMER    
    Private COVAFTLServicio As New CCOVAFTLServicio()
    Private ReportingServicio As New CReportingServicio()
    Private dtValmer As New System.Data.DataTable()

    Public Function ObtieneDatos() As DataTable
        Try
            Me.Show()

            Dim strRutaValmer As String
            Dim intBitacoraValmer As Integer

            strRutaValmer = COVAFTLServicio.ObtieneRutaValmer()

            intBitacoraValmer = CUtileria.GrabarBitacora("ReportingBancomer", "Carga datos VALMER", "Carga datos desde " + strRutaValmer + " para el calculo de información")

            dtValmer = ReportingServicio.ObtieneTablaValmer(strRutaValmer)

            If dtValmer Is Nothing Then
                dtValmer = New DataTable()
                dtValmer.Columns.Add("Instrumento")

                MessageBox.Show("No se cargó correctamente la información de VALMER", "Carga VALMER", MessageBoxButton.OK, MessageBoxImage.Warning)
            End If

            CUtileria.CompletarRegBitacora(intBitacoraValmer)

            Me.Close()

            Return dtValmer

        Catch ex As Exception
            Dim intErrorValmer As Integer = CUtileria.GrabarBitacora("ReportingBancomer", "Carga datos VALMER", ex.Message)
            CUtileria.CompletarRegBitacora(intErrorValmer)

            Mouse.OverrideCursor = Cursors.Arrow

            MessageBox.Show("Error TI500. " & ex.Message, "Carga datos VALMER", MessageBoxButton.OK, MessageBoxImage.Error)

            Me.Close()

            Return Nothing
        End Try
    End Function
End Class
